﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace MaterialDemo.DataEntity.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "DepartmentInfo",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DepartmentId = table.Column<string>(maxLength: 16, nullable: false),
                    DepartmentName = table.Column<string>(maxLength: 16, nullable: false),
                    LeaderId = table.Column<string>(maxLength: 16, nullable: false),
                    ParentId = table.Column<string>(maxLength: 16, nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DepartmentInfo", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Goods_Category",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CategoryName = table.Column<string>(maxLength: 16, nullable: false),
                    Description = table.Column<string>(maxLength: 32, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Goods_Category", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Goods_ConsumableInfo",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    GoodsId = table.Column<string>(maxLength: 16, nullable: false),
                    CategoryId = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 16, nullable: false),
                    Specification = table.Column<string>(maxLength: 32, nullable: true),
                    Num = table.Column<double>(nullable: false),
                    Unit = table.Column<string>(maxLength: 8, nullable: false),
                    Money = table.Column<decimal>(type: "money", nullable: true),
                    WarningNum = table.Column<double>(nullable: true),
                    DelFlag = table.Column<byte>(nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Goods_ConsumableInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Goods_ConsumableInput",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    GoodsId = table.Column<string>(maxLength: 16, nullable: false),
                    Num = table.Column<double>(nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    AddUserId = table.Column<string>(maxLength: 16, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Goods_ConsumableInput", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Goods_EquipmentInfo",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    GoodsId = table.Column<string>(maxLength: 16, nullable: false),
                    CategoryId = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 16, nullable: false),
                    Specification = table.Column<string>(maxLength: 32, nullable: true),
                    Num = table.Column<double>(nullable: false),
                    Unit = table.Column<string>(maxLength: 8, nullable: false),
                    Money = table.Column<decimal>(type: "money", nullable: true),
                    DelFlag = table.Column<byte>(nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    Description = table.Column<string>(maxLength: 16, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Goods_EquipmentInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Goods_EquipmentInput",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    GoodsId = table.Column<string>(maxLength: 16, nullable: false),
                    Num = table.Column<double>(nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    AddUserId = table.Column<string>(maxLength: 16, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Goods_EquipmentInput", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Log",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Decription = table.Column<string>(maxLength: 128, nullable: true),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Log", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PowerInfo",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PowerId = table.Column<string>(maxLength: 16, nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Description = table.Column<string>(maxLength: 32, nullable: true),
                    Sort = table.Column<double>(nullable: true),
                    ActionUrl = table.Column<string>(maxLength: 128, nullable: false),
                    ParentId = table.Column<string>(maxLength: 16, nullable: true),
                    MenuIconUrl = table.Column<string>(maxLength: 32, nullable: true),
                    HttpMethod = table.Column<string>(maxLength: 4, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PowerInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "R_RoleInfo_PowerInfo",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RoleId = table.Column<string>(maxLength: 16, nullable: false),
                    PowerId = table.Column<string>(maxLength: 16, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_R_RoleInfo_PowerInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "R_UserInfo_RoleInfo",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserId = table.Column<string>(maxLength: 16, nullable: false),
                    RoleId = table.Column<string>(maxLength: 16, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_R_UserInfo_RoleInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RoleInfo",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RoleId = table.Column<string>(maxLength: 16, nullable: false),
                    RoleName = table.Column<string>(maxLength: 16, nullable: false),
                    Description = table.Column<string>(maxLength: 32, nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    DelFlag = table.Column<byte>(nullable: false),
                    DelTime = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserInfo",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserId = table.Column<string>(maxLength: 16, nullable: false),
                    UserName = table.Column<string>(maxLength: 16, nullable: false),
                    PhoneNum = table.Column<string>(maxLength: 16, nullable: true),
                    Email = table.Column<string>(maxLength: 32, nullable: true),
                    DepartmentId = table.Column<string>(maxLength: 16, nullable: false),
                    Sex = table.Column<byte>(nullable: false),
                    PassWord = table.Column<string>(unicode: false, fixedLength: true, maxLength: 32, nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    DelFlag = table.Column<byte>(nullable: false),
                    DelTime = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "WorkFlow_Instance",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    InstanceId = table.Column<string>(maxLength: 64, nullable: false),
                    ModelId = table.Column<int>(nullable: false),
                    UserId = table.Column<string>(maxLength: 16, nullable: false),
                    Status = table.Column<byte>(nullable: false),
                    Description = table.Column<string>(maxLength: 64, nullable: true),
                    Reason = table.Column<string>(maxLength: 64, nullable: true),
                    NextReviewer = table.Column<string>(maxLength: 16, nullable: true),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    OutNum = table.Column<double>(nullable: false),
                    OutGoodsId = table.Column<string>(maxLength: 16, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkFlow_Instance", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "WorkFlow_InstanceStep",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    InstanceId = table.Column<string>(maxLength: 64, nullable: false),
                    ReviewerId = table.Column<string>(maxLength: 16, nullable: false),
                    ReviewReason = table.Column<string>(maxLength: 64, nullable: true),
                    ReviewStatus = table.Column<byte>(nullable: false),
                    ReviewTime = table.Column<DateTime>(type: "datetime", nullable: true),
                    NextReviewerId = table.Column<string>(maxLength: 16, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkFlow_InstanceStep", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "WorkFlow_Model",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(maxLength: 32, nullable: false),
                    AddTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    DelFlag = table.Column<byte>(nullable: false),
                    Description = table.Column<string>(maxLength: 64, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkFlow_Model", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_DepartmentInfo",
                table: "DepartmentInfo",
                column: "DepartmentId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_PowerInfo",
                table: "PowerInfo",
                column: "PowerId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_RoleInfo",
                table: "RoleInfo",
                column: "RoleId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_UserInfo",
                table: "UserInfo",
                column: "UserId",
                unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "DepartmentInfo");

            migrationBuilder.DropTable(
                name: "Goods_Category");

            migrationBuilder.DropTable(
                name: "Goods_ConsumableInfo");

            migrationBuilder.DropTable(
                name: "Goods_ConsumableInput");

            migrationBuilder.DropTable(
                name: "Goods_EquipmentInfo");

            migrationBuilder.DropTable(
                name: "Goods_EquipmentInput");

            migrationBuilder.DropTable(
                name: "Log");

            migrationBuilder.DropTable(
                name: "PowerInfo");

            migrationBuilder.DropTable(
                name: "R_RoleInfo_PowerInfo");

            migrationBuilder.DropTable(
                name: "R_UserInfo_RoleInfo");

            migrationBuilder.DropTable(
                name: "RoleInfo");

            migrationBuilder.DropTable(
                name: "UserInfo");

            migrationBuilder.DropTable(
                name: "WorkFlow_Instance");

            migrationBuilder.DropTable(
                name: "WorkFlow_InstanceStep");

            migrationBuilder.DropTable(
                name: "WorkFlow_Model");
        }
    }
}
